package com.wy.panda.common.base.dao;

import java.util.List;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById;
import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn;
import com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill;

/**
 * 
 *
 * @author WangYuan
 * @since 2020年9月29日 下午4:26:25
 */
public class PandaSqlInjector extends DefaultSqlInjector {

	@Override
	public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
		List<AbstractMethod> methodList = super.getMethodList(mapperClass);
        methodList.add(new InsertBatchSomeColumn(item -> item.getFieldFill() != FieldFill.UPDATE 
        		|| item.getInsertStrategy() != FieldStrategy.NEVER));
        methodList.add(new AlwaysUpdateSomeColumnById(item -> item.getUpdateStrategy() != FieldStrategy.NEVER 
        		|| item.getFieldFill() != FieldFill.INSERT));
        methodList.add(new LogicDeleteByIdWithFill());
		return methodList;
	}

}
